<template>
  <div>
    <el-dialog title="复制H单" :visible.sync="CopyHouseOrderVisible">
    <el-row :gutter="15">
      <el-col :span="3">
        <span>运单号</span>
      </el-col>
      <el-col :span="3">
        <el-input v-model="waybillNo" size="mini"
                  style="width: 200px" placeholder="请输入运单号"></el-input>
      </el-col>
      <el-col :span="6">
        <el-button type="primary" icon="el-icon-search" size="mini" style="margin-left: 100px" @click="queryWaybillInfo">搜索</el-button>
      </el-col>
    </el-row>
    <div style="height: 30px;"></div>
    <el-row :gutter="12">
      <el-col :span="6">
        <span style="margin-left: 50px">发件人</span>
        <el-divider></el-divider>
      </el-col>
      <el-col :span="6">
        <span>收件人</span>
        <el-divider></el-divider>
      </el-col>
      <el-col :span="6">
        <span>通知人</span>
        <el-divider></el-divider>
      </el-col>
      <el-col :span="3">
        <span>代理</span>
        <el-divider></el-divider>
      </el-col>
    </el-row>
    <el-row>
      <el-col
        :sm="24"
        :md="24"
        :lg="22"
        :xl="22"
        class="flex  align-center justify-start"
      >
    <div class="title-icon " style="margin-left: 50px">
      <span>H单 </span>
    </div>
    <span style="margin-left: 20px">H单号:</span><span >{{ HInfo.houseNumber }}</span>
      </el-col>
    </el-row>
    <el-row :gutter="12">
      <el-col :span="2">
        <el-radio v-model="checkM" label="1">{{''}}</el-radio>
      </el-col>
      <el-col :span="4">
        <span style="margin-left: 30px">{{ HInfo.houseNumberSender }}</span>
      </el-col>
      <el-col :span="6">
        <span >{{ HInfo.houseNumberReceiver }}</span>
      </el-col>
      <el-col :span="6">
        <span >{{ HInfo.houseNumberNotifier }}</span>
      </el-col>
      <el-col :span="3">
        <span >{{ HInfo.houseNumberAgent }}</span>
      </el-col>
    </el-row>
      <div style="height: 100px;"></div>
      <div style="margin-left: 700px">
        <el-button size="mini" @click="CopyHouseOrderVisible = false">取 消</el-button>
        <el-button size="mini" type="primary" @click="copyHInfo"
        >确 定</el-button
        >
      </div>
    </el-dialog>
  </div>
</template>
<script>
import { ajax } from "@/store/yg/common/utils";

export default {
  props: {
    waybillId: {
      type: Number,
      default: ""
    }
    },
  data() {
    return {
      show: "2",
      toUpDialog: false,
      CopyHouseOrderVisible: false,
      waybillNo: null,
      checkM: null,
      restaurants: [],
      HInfo: {
        id: 0,
        waybillId: 0,
        houseNumber: null, // H单号：
        houseNumberSender: null, // H单号：发件人
        houseNumberReceiver: null, // H单号：收件人
        houseNumberNotifier: null, // H单号：通知人
        houseNumberAgent: null // H单号：代理
      }
    };
  },
  mounted() {

  },
  methods: {
    queryWaybillInfo(){
      var param = {};
      const waybillNum =this.waybillNo;
      param["waybillNo"] = waybillNum;
      const attrs = {
        class: 'com.tofba.app.client.seaair.SeaAirExpressListClient'
      }
      ajax("initDataPickUpData", param,attrs).then(
        res => {
          if (res.code != 200) {
            this.$message.error(res.message);
          } else {
            if (null != res.data) {
              this.HInfo = res.data;
              console.log("查询获取的H单信息",this.HInfo);
            }
          }
        },
        error => {
          console.log(error);
        }
      );
    },
    close() {
      this.dialogTableVisible = false;
    },
    copyHInfo() {
      if(this.checkM==null){
        this.$message.error("请选择要复制的内容");
        return;
      }
      var param = this.HInfo;
      if(this.param=null){
        this.$message.error("未查询到要复制的信息");
      }else{
        param["id"]=this.waybillId;
        param["shippingMark"]=null;
        param["houseNumber"]=null;
        const attrs = {
          class: 'com.tofba.app.client.seaair.SeaAirExpressListClient'
        }
        ajax("changeHInfo", param,attrs).then(
          res => {
            console.log(res);
            if (res.code != 200) {
              this.$message.error(res.message);
            } else {
              this.$message.success("保存成功");
              this.CopyHouseOrderVisible=false;
              window.location.reload(true);
            }
          },
          error => {
            console.log(error);
          }
        );
      }
    }
  }
};
</script>

<style scoped>
</style>
